package com.pshcp.service;

import com.framework.util.SystemUtil;
import com.pshcp.common.enums.CommonStatusEnum;
import com.pshcp.domain.model.ExternalLog;
import com.pshcp.mapper.ExternalLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2023/3/17 15:57
 */
@Service
public class ExternalLogService {

    @Autowired
    private ExternalLogMapper externalLogMapper;

    public int insert(ExternalLog externalLog) {
        externalLog.setId(SystemUtil.getId());
        externalLog.setStatus(CommonStatusEnum.INIT.getCode());
        externalLog.setCreatedTime(new Date());
        return externalLogMapper.insert(externalLog);
    }

    public List<ExternalLog> getExternalLogList(String pshcpTraceId) {
        Example example = new Example(ExternalLog.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("pshcpTraceId", pshcpTraceId);
        return externalLogMapper.selectByExample(example);
    }
}
